s=input()
a,b=input().split()
n=len(s)
for i in range(n):
    if(s[n-i-1]==a or s[n-i-1]==b):
        print(n-i-1,s[n-i-1])


